package io.renren.modules.wms.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.wms.entity.DictInfoEntity;
import io.renren.modules.wms.service.DictInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 数据字典表
 *
 * @author lain
 * @email 494576412@qq.com
 * @date 2019-07-04 16:45:20
 */
@RestController
@RequestMapping("wms/dictinfo")
public class DictInfoController {
    @Autowired
    private DictInfoService dictInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wms:dictinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dictInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("wms:dictinfo:info")
    public R info(@PathVariable("id") Integer id){
		DictInfoEntity dictInfo = dictInfoService.getById(id);

        return R.ok().put("dictInfo", dictInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("wms:dictinfo:save")
    public R save(@RequestBody DictInfoEntity dictInfo){
		dictInfoService.save(dictInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wms:dictinfo:update")
    public R update(@RequestBody DictInfoEntity dictInfo){
		dictInfoService.updateById(dictInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wms:dictinfo:delete")
    public R delete(@RequestBody Integer[] ids){
		dictInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
